<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var point = {
        x: 0,
        y: 0,
        moveTo: {
          moveX: function(x) {
            console.log(this) // { moveX: function, moveY: function, x: 1, y: 1 }
            // 这是因为 console.log/dir/... 这类方法输出对象时会显示该对象在内存中最新的状态；
            // 内存的地址上是原始值是不能被修改，所以对象的话输出结果中 a 的值都已经被修改成最新的值
            this.x = x // point.moveTo.x = 1
          },

          moveY: function(y) {
            this.y = y // point.moveTo.y = 1
          }
        }
      }
      point.moveTo.moveX(1)
      point.moveTo.moveY(1)
      console.log(point.moveTo) // { moveX: function, moveY: function, x: 1, y: 1 }
      console.log(point.x) // 0
      console.log(point.y) // 0
      console.log(x) // x is not defined
      console.log(y) // y is not defined 此错误不会再浏览器显示
    </script>
  </body>
</html>
